/*
 * @Date: 2025-01-02 16:40:33
 * @Author: LiSong
 * @LastEditors: LiSong
 * @LastEditTime: 2025-03-26 09:46:42
 * @Description: 插槽数据主文件（包含相关配置）
 */
import { defineAsyncComponent } from 'vue'
// 收支预算表格
import SlotTableSzysFull from './modules/SlotTableSzysFull.vue'
// 评分项附件补录
import SlotPanelFilePfxBl from './modules/SlotPanelFilePfxBl.vue'

// 当前环境
const env = import.meta.env.MODE

// 不同环境的插槽配置
const slotsEnvs = {
  ad34: [
    {
      name: 'ProjectJxmbTable',
      label: '绩效目标面板',
      component: () => import('./modules/SlotPanelJxmb.vue')
    },
  ],
  ad35: [
    {
      name: 'ScoringRuleFilesPanel',
      label: '评分项附件补录',
      component: SlotPanelFilePfxBl,
    },
  ],
  ad51: [
    {
      name: 'FromSlotSbjlTable',
      label: '项目申报记录',
      component: () => import('./modules/SlotTableSbjl.vue')
    },
  ],
}
// 通用环境的插槽配置
const slotsBase = [
  {
    name: 'AttachmentPanel',
    label: '附件管理面板',
    component: () => import('./modules/SlotPanelFile.vue')
  },
  {
    name: 'SlotPanelFileNew',
    label: '附件管理面板[新]',
    component: () => import('./modules/SlotPanelFileNew.vue')
  },
  {
    name: 'ChangeAttachmentPanel',
    label: '变更附件面板',
    component: () => import('./modules/SlotPanelFileXmBg.vue')
  },
  {
    name: 'ProjectSzysTable',
    label: '收支预算表格',
    component: SlotTableSzysFull
  },
  {
    name: 'ProjectTzjhTable',
    label: '投资计划表格',
    component: () => import('./modules/SlotTableTzjh.vue')
  },
  {
    name: 'ProjectReviewPanel',
    label: '项目评分表格',
    component: () => import('./modules/SlotTableXmpf.vue')
  },
  {
    name: 'ProjectDeclareTable',
    label: '项目申报记录(赛马项目)',
    component: () => import('./modules/SlotTableSbjlBx.vue')
  },
  {
    name: 'SignUploadPanel',
    label: '签名图片上传',
    component: () => import('./modules/SlotPanelSignUpload.vue')
  },
  {
    name: 'ProjecZgEnter',
    label: '项目整改录入',
    component: () => import('./modules/SlotPanelXmzg.vue')
  },
  {
    name: 'IssuanceStatusPanel',
    label: '项目发行情况',
    component: () => import('./modules/SlotPanelFxqk.vue')
  },
  {
    name: 'ChangeHistoryTable',
    label: '项目变更记录',
    component: () => import('./modules/SlotTableBgls.vue')
  },
]
// 插槽配置
const slotFull = [
  ...slotsBase, ...(slotsEnvs[env] || []),
]
// 插槽模块
const slotModules = {}
function isFunction(value) {
  return value && (typeof value === 'function' || value instanceof Function || value.constructor === Function);
}
for (let item of slotFull) {
  if (!item.component) continue;
  slotModules[item.name] = isFunction(item.component)
                            ? defineAsyncComponent({ loader: item.component, delay: 80 })
                            : item.component
} 

export {
  slotFull,
  slotModules
}